package com.sxj.corejava.code07_面向对象.bms;

/**
 * @author 石小俊
 * 2024年07月17日 13:32
 */
public abstract class Account {

    // 准备一个初始的卡号,这个卡号所有类共有
    private static int initId = 1000;

    // 属性
    private int id;
    private String name;
    private String password;
    private String personId;
    private String phone;
    private double balance;

    public Account() {
        // 由于账户编号要求每次自增1
        // 在当前类中定义一个属于类的静态变量
        // 并为静态变量赋予一个初始值1000
        // 在创建对象时,每次创建完成之后将静态变量的+1
        this.id = initId++;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPersonId() {
        return personId;
    }

    public void setPersonId(String personId) {
        this.personId = personId;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    /**
     * 存款方法,不允许子类修改
     * @param money 存款的金额
     */
    public final void deposit(double money) {
        this.balance += money;
    }

    /**
     * 取款,子类根据业务需求进行重写,必须重写
     * @param money 取款金额
     * @return 是否取款成功
     */
    public abstract boolean withdrawMoney(double money);
}
